home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / dl_dos.pro < prev    next >
Text File  |  1997-07-08  |  4KB  |  137 lines

  1. ; $Id: dl_dos.pro,v 1.6 1997/03/13 16:59:30 ali Exp $
  2. ;
  3. ; Copyright (c) 1990-1997, Research Systems, Inc.  All rights reserved.
  4. ;    Unauthorized reproduction prohibited.
  5. ;
  6.  
  7. pro doc_file, name, outunit     ; print documentation for file 'name'
  8.     printf, outunit
  9.     printf, outunit, '----- Documentation for ',name
  10.     printf, outunit
  11.     openr, unit, name, /GET_LUN
  12.     line = ""
  13.     outflag = 0
  14.     readf, unit, line
  15.     while not eof(unit) and strpos(line, ";-") ne 0 do begin
  16.       if outflag then printf, outunit, strmid(line, 1, 132)
  17. ;
  18. ; output lines after line which starts with ";+"
  19. ;
  20.       if strpos(line, ";+") eq 0 then outflag = 1
  21.       readf, unit, line
  22.     endwhile
  23.     close, unit
  24. end
  25.  
  26. pro dl_dos, name, print=printflg, directory = direct
  27. ;+NODOCUMENT
  28. ; NAME:
  29. ;    DL_DOS
  30. ;
  31. ; PURPOSE:
  32. ;    Extract the documentation template of one or more procedures (DOS
  33. ;    version).
  34. ;
  35. ; CATEGORY:
  36. ;    Help, documentation.
  37. ;
  38. ; CALLING SEQUENCE:
  39. ;    DL_DOS        ;For prompting.
  40. ;    DL_DOS, Name     ;Extract documentation for procedure Name using
  41. ;                the current !PATH.
  42. ;
  43. ; INPUTS:
  44. ;    Name:    A string containing the name of the procedure or "*" for all.
  45. ;
  46. ; OPTIONAL INPUT PARAMETERS:
  47. ;    PRINT:    A keyword parameter which, if set to 1, sends the output
  48. ;        of DL_DOS to PRN:.  If PRINT is a string, it specifies the
  49. ;        name of a file that will contain the documentation.
  50. ;
  51. ;   DIRECTORY:    The directory to search.  If omitted, the current directory
  52. ;        and !PATH are used.
  53. ;
  54. ; OUTPUTS:
  55. ;    No explicit outputs.  Documentation is output using 'more' format
  56. ;    unless /PRINT is specified.
  57. ;
  58. ; COMMON BLOCKS:
  59. ;    None.
  60. ;
  61. ; SIDE EFFECTS:
  62. ;    Output is produced on terminal or printer.  If the current directory
  63. ;    is also one of the directories specified in !PATH or DIRECTORY,
  64. ;    documentation will be output twice for the specified module(s).
  65. ;
  66. ; RESTRICTIONS:
  67. ;    ??
  68. ;
  69. ; PROCEDURE:
  70. ;    Straightforward.
  71. ;
  72. ; MODIFICATION HISTORY:
  73. ;    SNG, Dec, 1990 - adapted from DOC_LIB_UNIX
  74. ;    AB, 21 September 1992, renamed from DOC_LIB_DOS to DL_DOS to
  75. ;        avoid DOS filename limitations.
  76. ;-
  77.  
  78. on_error,2              ;Return to caller if an error occurs
  79. if n_elements(name) eq 0 then begin    ;Interactive query?
  80.     name = ''
  81.     printflg = 0    
  82.     read, 'Name of procedure or * for all: ',name
  83.     read, 'Enter 1 for printer, 0 for terminal: ',printflg
  84.     endif
  85.  
  86. name = strlowcase(name)        ;make it always lower case
  87.  
  88. ;
  89. ; if DIRECTORY not specified, use !path
  90. ;
  91. if n_elements(direct) eq 0 then begin
  92.   cd, current=curr
  93.   curr = strlowcase(curr)       ; make lower case
  94. ;
  95. ;   add the current directory to the search path if it is not already there
  96. ;
  97.   if strpos(!path, curr) eq -1 then path = ".;" + !path else path = !path
  98. endif else path = direct    ; otherwise use DIRECTORY
  99. ;
  100. ; determine where output is going and open as a file
  101. ;
  102. if n_elements(printflg) eq 0 then begin
  103.   outunit=-1
  104. endif else begin
  105.   printflg = strtrim(printflg, 2)
  106.   case printflg of
  107.     '0':  outunit=-1                                            ; terminal
  108.     '1':  openw, outunit, 'prn:', /GET_LUN                      ; printer
  109.     else:   openw, outunit, printflg, /GET_LUN                  ; file
  110.   endcase
  111. endelse
  112. ;
  113. ; loop for every directory in path
  114. ;
  115. while strlen(path) gt 0 do begin ; Find it
  116.     i = strpos(path, ";")
  117.     if i lt 0 then i = strlen(path)
  118.     name_path = strmid(path, 0, i)
  119.     cd, name_path
  120.     name_path = name_path + '\'
  121. ;
  122. ;           file_list contains all file(s) to document
  123. ;
  124.     file_list = findfile(name_path + name + '.pro',count=n_files)
  125.     n_files = n_files - 1                       ; since indexed from zero
  126.     for n = 0, n_files do begin                  ; document every file
  127.         doc_file, file_list[n], outunit
  128.         printf, outunit, ' '     ; output form feed to start next at top of page
  129.     endfor
  130.     path = strmid(path, i + 1, strlen(path))
  131. endwhile
  132. if outunit ne -1 then begin
  133.   FREE_LUN, outunit
  134. endif
  135. cd, curr
  136. end
  137.